#include<stdio.h>
#include<string.h> 
int main(){
	int x,n,i,a,b,c;
	int isx = 0;
	char p[10];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		for(x=1000;x<=9999;x++){
			if(x%a==0 && (x+1) % b == 0 && (x+2) % c == 0){
				isx = 1;
				break;
			}
		}
		if(isx==1)
		   p[i]=x;
		else{
		   p[i]=-1;
		}
		isx=0;
	}
	for(i=0;i<n;i++){
		if(p[i]==-1){
			printf("Impossible\n");
		}
		else if(p[i]!=-1){
			printf("%d\n",p[i]);
		}
	}
	return 0;
} 
